package com.imooc.article.stream;

import com.imooc.pojo.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

/**
 * @Project_name: imooc-news-dev
 * @Description:  开启绑定器  ，绑定通道  channel
 * @Author: Levi
 * @Date: 2021/4/2 16:23
 */
@Service
@EnableBinding(MyStreamChannel.class)
public class StreamMsgServiceImpl implements StreamMsgService {
    @Autowired
    private MyStreamChannel myStreamChannel;
    @Override
    public void sendMsg() {
        AppUser user = new AppUser();
        user.setId("10000");
        user.setNickname("路飞");
        myStreamChannel.output()
                .send(MessageBuilder.withPayload(user).build());
        System.out.println("stream生产者发送消息~~~~");

    }
}
